package com.arpa.ntocc.common.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: Allen chen
 * @Date 2020/8/17
 * @Description:
 */
public enum EmploymentTypeEnum implements IEnum<String> {
    /**
     * 用工类型枚举
     */
    REGULAR("regular", "正式工"),
    TEMP("temp", "临时工"),
    OUT("out", "外包工");


    /**
     * 值
     */
    private String value;

    /**
     * 描述
     */
    private String desc;

    EmploymentTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String translate(String value){
        EmploymentTypeEnum item = ENUM_MAP.get(value);
        if(item != null){
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    private static final Map<String, EmploymentTypeEnum> ENUM_MAP = new HashMap();

    static {
        for(EmploymentTypeEnum item: values()){
            ENUM_MAP.put(item.getValue(), item);
        }
    }

    public static EmploymentTypeEnum getEnumByValue(String value) {
        return ENUM_MAP.get(value);
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

}
